﻿using FitbitAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FitbitManager.WrapperLibrary
{
    public class WrapperFitbitClient
    {
        private FitbitAPI.FitbitClient client;

        private WrapperFitbitClient(string AccessToken, string AccessSecret)
        {
            client = new FitbitAPI.FitbitClient(ConsumerInfo.ConsumerKey, ConsumerInfo.ConsumerSecret, AccessToken, AccessSecret);
        }

        public static WrapperFitbitClient CreateFitbitClient(string AccessToken, string AccessSecret)
        {
            return new WrapperFitbitClient(AccessToken, AccessSecret);
        }

        public void RemoveSubscription(string OwnerID)
        {
            client.RemoveSubscription(APICollectionType.user, OwnerID);
        }

        /// <returns>Returns the OwnerID</returns>
        public string AddSubscription(string OwnerID)
        {
            var subscription = client.AddSubscription(APICollectionType.activities, OwnerID);
            return subscription.OwnerId;
        }

        public bool ExistGameUpSubscription()
        {
            return client.GetSubscriptions().Exists(x => x.CollectionType == APICollectionType.activities);
        }

        public Activity GetDayActivity(DateTime activityDate)
        {
            return client.GetDayActivity(activityDate);
        }
    }
}
